using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpCompoundSubquery : OracleLpSubquery
	{
		private OracleLpSubquery m_vSubquery;

		public override OracleLpSubqueryType SubqueryType => OracleLpSubqueryType.Compound;

		public OracleLpSubquery Subquery
		{
			get
			{
				return m_vSubquery;
			}
			internal set
			{
				m_vSubquery = value;
				m_vSubquery.Parent = this;
			}
		}

		public OracleLpCompoundSubquery(OracleLpStatementElement parent)
			: base(parent)
		{
		}

		public override void Resolve()
		{
			m_vColumnDescriptors = m_vSubquery.ColumnDescriptors;
		}

		public override void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			m_vSubquery.RetrieveNamedObjectReferences(statement);
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			base.ToString(sb);
			sb.Append(depthIndent);
			sb.Append("Compound subquery:\n");
			m_vSubquery.ToString(sb);
			sb.Append('\n');
		}
	}
}
